import { sphHttp } from '@/utils/request.ts'
import type { IPayCode, IReqParams, IReqTradeInfo, ITradeInfo } from '@/types/order'


/**
 * @description  获取交易页购买商品列表信息
 * @param
 *
 */
export const reqTrade = () => {
  return sphHttp<ITradeInfo>('/api/order/auth/trade', "GET")
}


/**
 * @description  提交订单
 * @param  tradeNo  订单id
 *
 */
export const reqSubmitOrder = (data: IReqTradeInfo) => {
  return sphHttp(`/api/order/auth/submitOrder?tradeNo=${data.tradeNo}`, "POST", data)
}

/**
 * @description  提交订单
 * @param  orderId  订单id
 *
 */
export const reqPayInfo = (orderId: string) => {
  return sphHttp<IPayCode>(`/api/payment/weixin/createNative/${orderId}`, "GET")
}

/**
 * @description  查询订单的支付状态
 * @param  orderId 订单id
 *
 */
export const reqPaySuccess = (orderId: string) => {
  return sphHttp(`/api/payment/weixin/queryPayStatus/${orderId}`, "GET")
}

/**
 * @description  获取我的订单列表
 * @param  page  页码
 * @param  limit  每页展示数量
 *
 */
export const reqAuthOrder = (params: IReqParams) => {
  return sphHttp(`/api/order/auth/${params.page}/${params.limit}`, "GET")
}
